<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/base}">
<head>
    <link href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.1.0/github-markdown.min.css" rel="stylesheet">
</head>
<body>
<div layout:fragment="content">
    <div class="row">
        <div class="col-md-8">
            <div class="card mb-4 shadow-sm" th:each="post : ${posts}">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <h2 class="card-title">
                            <a th:href="@{'/post/' + ${post.id}}" 
                               th:text="${post.title}"
                               class="text-decoration-none text-dark">文章标题</a>
                        </h2>
                        <div>
                            <a th:href="@{'/post/' + ${post.id} + '/edit'}" class="btn btn-primary btn-sm me-1">
                                <i class="bi bi-pencil"></i>
                            </a>
                            <form th:action="@{'/post/' + ${post.id} + '/delete'}" method="post" style="display: inline;">
                                <input type="hidden" name="_method" value="DELETE" />
                                <input type="hidden" th:name="${_csrf?.parameterName}" th:value="${_csrf?.token}" />
                                <button type="submit" class="btn btn-danger btn-sm" 
                                        onclick="return confirm('确定要删除这篇文章吗？');">
                                    <i class="bi bi-trash"></i>
                                </button>
                            </form>
                        </div>
                    </div>
                    <p class="card-text text-muted">
                        <small>
                            <i class="bi bi-calendar"></i>
                            <span th:text="${#temporals.format(post.createTime, 'yyyy-MM-dd HH:mm')}">时间</span>
                        </small>
                    </p>
                    <p class="card-text markdown-body" 
                       th:utext="${#strings.abbreviate(post.content, 300)}">文章内容预览...</p>
                    <a th:href="@{'/post/' + ${post.id}}" 
                       class="btn btn-outline-primary btn-sm">阅读更多</a>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card mb-4 shadow-sm">
                <div class="card-body">
                    <h5 class="card-title">关于博客</h5>
                    <p class="card-text">这是一个基于Java Spring Boot开发的个人博客系统，欢迎分享和交流<br/>关于诗社的建议，详联csutianlang@gmail.com</p>
                    <a href="/post/new" class="btn btn-primary">写文章</a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html> 